using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using UnityEngine.Video;

/****************************************************
// 功能：大厅窗口
// | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
// | Copyright (c) 2021-2025 聊来 All rights reserved.
// | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">聊来</a> )
// | @Author: 贯彻己道的云 <18970881148@qq.com>
// | DateTime: 2025/2/21 21:26:3
*****************************************************/

public class LobbyWindow : BaseWindow
{
    private Image avatar;
    private Text userName;
    private VideoPlayer videoPlayer;
    private UnityWebRequest web;

    private void Awake()
    {
        avatar = FindChildTransform(transform, "avatar").GetComponent<Image>();
        userName = FindChildTransform(transform, "userName").GetComponent<Text>();
        videoPlayer = FindChildTransform(transform, "videoPlayer").GetComponent<VideoPlayer>();
    }

    protected override void InitWindows()
    {
        base.InitWindows();
        audioManager.PlayBGMusic(Constants.LOBBY);
        
        SetText(userName, model.userInfo.userName);

        StartCoroutine(SetDownImageToLocal(avatar, model.userInfo.avatar, "avatar"));
        
        web = UnityWebRequest.Get("http://images.pxphjr.cn/lobby.mp4");
        StartCoroutine(SetDownViewPlayerToLocal(web, videoPlayer,"lobby.mp4"));
    }

    /// <summary>
    /// 排位赛
    /// </summary>
    public void OnRankingButton()
    {
        audioManager.PlayUIAudio("matchBtnClick");
        ui.jump(WindowName.Group, "多人排位");
    }

    public void OnFightButton()
    {
        audioManager.PlayUIAudio("matchBtnClick");
        
        ui.jump(WindowName.Group, "竞技对抗");
        
    }
}
